{layout name="public/layout" /}
<div class="main">
    {if $op=='display'}
    <div class="panel panel-info">
        <div class="panel-heading">当前数量： {$total}</div>
        <div class="panel-body">
            <form id="myform" action="./index.php" method="get" class="form-horizontal" role="form">
                <input type="hidden" name="c" value="site"/>
                <input type="hidden" name="a" value="entry"/>
                <input type="hidden" name="m" value="{$_P['m']}"/>
                <input type="hidden" name="do" value="platform"/>
                <div class="form-group clearfix">
                    <div class="form-group">
                        <label class="col-xs-12 col-sm-3 col-md-1 control-label">名称</label>
                        <div class="col-sm-3 col-xs-3 col-md-3">
                            <input class="form-control" name="keyword" placeholder="输入名称" type="text"
                                   value="{$keyword}">
                        </div>
                        <div class="col-sm-1 col-lg-1 col-md-1 col-xs-6">
                            <button class="btn btn-primary"><i class="fa fa-search"></i> 搜索</button>
                            <input type="hidden" name="__token__" value="{$Request.token}"/>
                        </div>
                        <div class="col-sm-4 col-lg-3 col-md-4 col-xs-6">
                            <div class="btn-group">
                                <a class="btn btn-default"
                                   href="{php echo createWebUrl('platform',array('op'=>'display','status'=>0));}">回收站</a>
                                <a class="btn btn-success"
                                   href="{php echo createWebUrl('platform',array('op'=>'add'));}">新增</a>
                               {if $_G['isSuperAdmin']}
                                   <button type="button" class="btn btn-info" id="add_txt">上传验证文件</button>
                               {/if}
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <div class="panel panel-default">
        <div class="panel-body table-responsive">
            <table class="table table-hover">
                <thead class="navbar-inner">
                <tr>
                    <th style="width:50px;">序号</th>
                    <th style="width:120px;">名称</th>
                    <th style="width:120px;">logo</th>
                    <th style="width:120px;">类型</th>
                    <th style="width:120px;">appid</th>
                    <th style="width:120px;">支付商户号</th>
                    <th style="width:120px;">证书</th>
                    <th style="width:120px;">模板消息</th>
                    <th style="width:100px; text-align:right;" class="showSjAddress">操作</th>
                </tr>
                </thead>
                <tbody>
                {loop $list $i $item}
                <tr>
                    <td>{$item['id']}</td>
                    <td>{$item['name']}</td>
                    <td><img src="{$item.logo}" alt="" width="42" style="border-radius: 3px;"></td>
                    <td>
                        {if $item['platform_type']==1}
                        <span class="label label-success">微信小程序</span>
                        {elseif $item['platform_type']==2}
                        <span class="label label-info">微信公众号</span>
                        {/if}
                    </td>
                    <td>{$item['appid']}</td>
                    <td>{$item['mchid']}</td>
                    <td>
                        {if $item['iscert']==1}
                        <span class="label label-success">已上传</span>
                        {else}
                        <span class="label label-info">未上传</span>
                        {/if}
                    </td>
                    <td>
                        {if $item['istmp']==1}
                        <span class="label label-success">已设置</span>
                        {else}
                        <span class="label label-info">未设置</span>
                        {/if}
                    </td>
                    <td>
                        <div class="btn-group">
                            <a class="btn btn-info btn-sm"
                               href="{php echo createWebUrl('platform', array('id' =>$item['id'],'themeid'=>$themeid,'op'=>'set_tmp'))}"
                               title="模板"><i class="icon-edit"></i>模板</a>
                            <a class="btn btn-primary btn-sm"
                               href="{php echo createWebUrl('platform', array('id' =>$item['id'],'themeid'=>$themeid,'op'=>'edit'))}"
                               title="编辑"><i class="icon-edit"></i>编辑</a>
                            {if $item['status']==0}
                            <a class="btn btn-danger btn-sm"
                               href="{php echo createWebUrl('platform', array('id' =>$item['id'],'themeid'=>$themeid,'op'=>'delete'))}" onclick="if(!confirm('确定撤底删除吗，无法恢复！')) return false;"
                               title="删除"><i class="icon-edit"></i>删除</a>
                            <a class="btn btn-success btn-sm"
                               href="{php echo createWebUrl('platform', array('id' =>$item['id'],'themeid'=>$themeid,'op'=>'recover'))}"
                               title="恢复"><i class="icon-edit"></i>恢复</a>
                            {/if}
                        </div>
                    </td>
                </tr>
                {/loop}
                </tbody>
            </table>
        </div>
        {$pager}
    </div>
    {elseif $op=='edit' || $op=='add'}
    <div class="panel panel-default" role="tabpanel">
        <div class="panel-body">
            <form action="{php echo createWebUrl('platform', array('op' => 'save'))}" method="post"
                  enctype="multipart/form-data" class="form-horizontal" role="form" name="form2" id="form2"
                  style="padding:10px;">
                <input type="hidden" name="id" value="{$item['id']}" id="id"/>
                <div class="panel-heading">基本信息</div>
                <div class="panel-body">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">类型</label>
                        <div class="col-sm-8">
                            {if $item['platform_type']}
                            {if $item['platform_type'] ==1}
                            微信小程序
                            {else}
                            微信公众号
                            {/if}
                            <input type="hidden" name="platform_type" value="{$item['platform_type']}"
                                   id="platform_type"/>
                            {else}
                            <input type="radio" name="platform_type" value="1" checked> 微信小程序</label>
                            <input type="radio" name="platform_type" value="2"> 微信公众号</label>
                            {/if}
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">
                            <span style='color:red'>*</span>名称</label>
                        <div class="col-sm-8 col-xs-12">
                            <input type="text" class="form-control" placeholder="" name="name" value="{$item['name']}">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">
                            <span style='color:red'>*</span>appid</label>
                        <div class="col-sm-8 col-xs-12">
                            <input type="text" class="form-control" placeholder="" name="appid"
                                   value="{$item['appid']}">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">
                            <span style='color:red'>*</span>appSecret</label>
                        <div class="col-sm-8 col-xs-12">
                            <input type="text" class="form-control" placeholder="" name="secret"
                                   value="{$item['secret']}">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">
                            <span style='color:red'>*</span>账号</label>
                        <div class="col-sm-8 col-xs-12">
                            <input type="text" class="form-control" placeholder="" name="account"
                                   value="{$item['account']}">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">
                            <span style='color:red'>*</span>原始ID</label>
                        <div class="col-sm-8 col-xs-12">
                            <input type="text" class="form-control" placeholder="" name="original"
                                   value="{$item['original']}">
                        </div>
                    </div>
                </div>

                <div class="panel-heading">支付信息</div>
                <div class="panel-body">
                    <div class="form-group">
                        <label for="" class="control-label col-sm-2">支付商户号</label>
                        <div class="col-sm-8 col-xs-12">
                            <input type="text" name="mchid" value="{$item['mchid']}" class="form-control"
                                   placeholder="">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="" class="control-label col-sm-2">支付秘钥</label>
                        <div class="col-sm-8 col-xs-12">
                            <input type="text" name="apikey" value="{$item['apikey']}" id="apikey" class="form-control"
                                   placeholder="">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="" class="control-label col-sm-2">支付证书续号</label>
                        <div class="col-sm-8 col-xs-12">
                            <input type="text" name="serial_no" value="{$item['serial_no']}" class="form-control"
                                   placeholder="">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="" class="control-label col-sm-2">apiclient_cert.pem 证书</label>
                        <span class="text-success  col-sm-4">{if $item['apiclient_cert']}已上传{/if}</span>
                        <div class="form-controls col-sm-3 pull-right">
                            <input type="file" id="apiclient_cert" name="apiclient_cert" accept=".pem">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="" class="control-label col-sm-2">apiclient_key.pem 证书</label>
                        <span class="text-success  col-sm-4">{if $item['apiclient_key']}已上传{/if}</span>
                        <div class="form-controls col-sm-3 pull-right">
                            <input type="file" id="apiclient_key" name="apiclient_key" accept=".pem">
                        </div>
                    </div>
                </div>

                <div class="panel-heading">公众平台通信</div>
                <div class="panel-body">
                    <div class="form-group">
                        <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">URL</label>
                        <div class="col-sm-8 col-xs-12">
                            <input type="text" class="form-control" placeholder="" name="server_url"
                                   value="{$item['server_url']}" disabled>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">Token</label>
                        <div class="col-sm-8 col-xs-12">
                            <input type="text" class="form-control" placeholder="" name="__token__" value="{$Request.token}"
                                   disabled>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">EncodingAESKey</label>
                        <div class="col-sm-8 col-xs-12">
                            <input type="text" class="form-control" placeholder="" name="encodingaeskey"
                                   value="{$item['encodingaeskey']}" disabled>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <a class="btn btn-danger btn-sm"
                       href="{php echo createWebUrl('platform', array('id' =>$_P['id'],'themeid'=>$themeid,'op'=>'delete'))}" onclick="if(!confirm('确定删除吗！')) return false;"
                       title="删除"><i class="icon-edit"></i>{if $item['status']==0}撤底删除{else}删除{/if}</a>
                    {if $item['status']==0}
                    <a class="btn btn-info btn-sm"
                       href="{php echo createWebUrl('platform', array('id' =>$_P['id'],'themeid'=>$themeid,'op'=>'restore'))}"
                       title="恢复"><i class="icon-edit"></i>恢复</a>
                    {/if}
                    <button type="submit" class="btn btn-primary">确定</button>
                </div>
            </form>
        </div>
    </div>
    {elseif $op=='get_tmp'}
    <div class="panel-body">
        <form action="{php echo createWebUrl('platform', array('op' => 'save_tmp'))}" method="post" enctype="form-data"
              class="form-horizontal" role="form" name="form3" style="padding:10px;">
            <input type="hidden" name="id" value="{$id}"/>
            <div class="panel-heading">基本信息</div>
            <div class="panel-body">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">拼团成功通知</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control" placeholder="" name="mb_group_success"
                               value="{$item['mb_group_success']}">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">预约到店提醒</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control" placeholder="" name="mb_group_goshop"
                               value="{$item['mb_group_goshop']}">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">活动进度提醒</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control" placeholder="" name=" mb_group_progress"
                               value="{$item['mb_group_progress']}">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">砍价成功通知</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control" placeholder="" name="mb_bargain_success"
                               value="{$item['mb_bargain_success']}">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">砍价进度通知</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control" placeholder="" name="mb_bargain_progress"
                               value="{$item['mb_bargain_progress']}">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">砍价结果通知</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control" placeholder="" name="mb_bargain_result"
                               value="{$item['mb_bargain_result']}">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">助力成功通知</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control" placeholder="" name="mb_help_success"
                               value="{$item['mb_help_success']}">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">预售：新品开售提醒</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control" placeholder="" name="mb_presale_new"
                               value="{$item['mb_presale_new']}">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">预售：预约商品开售通知</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control" placeholder="" name="mb_presale_sale"
                               value="{$item['mb_presale_sale']}">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">预售：预售尾款支付提醒</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control" placeholder="" name="mb_presale_payment"
                               value="{$item['mb_presale_payment']}">
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="submit" class="btn btn-primary">提交</button>
            </div>
        </form>
    </div>
    {/if}
</div>
<script type="text/javascript">

    layui.use(['upload','layer'], function(){
        var upload = layui.upload;
        var layer = layui.layer;
        //执行实例
        var url = "{php echo createWebUrl('platform', array('op' => 'uploadtxt'),true)}";
        upload.render({
            elem: '#add_txt' //绑定元素
            ,url: url //上传接口
            ,exts:'txt'
            ,acceptMime:'txt'
            ,accept:'file'
            ,size:1
            ,done: function(res){
                layer.msg(res.msg);
            }
            ,error: function(){
                layer.msg('网络错误');
            }
        });
    });

    function jump() {
        layer.msg('正在准备下载');
    }

    function submitForm() {
        var form = document.getElementById("myform");
        form.submit();
    }

</script>
